//
//  ZilneView.m
//  YZZX
//
//  Created by Easaa on 15/5/11.
//  Copyright (c) 2015年 Easaa. All rights reserved.
//

#import "ZilneView.h"

@implementation ZilneView
{
    UIScrollView    *_scrollviewBg;
}

-(id)initWithFrame:(CGRect)frame Data:(NSMutableArray*)arry
{
    self = [super initWithFrame:frame];
    if(self)
    {
        self.DataArry =arry;
    //ZilneListDataModel
    //560/780
        
        [self creatZilneView];
    }
    
    return self;
}


-(void)creatZilneView
{


    
    _scrollviewBg = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, Dev_ScreenWidth, Dev_ScreenHeight-64-30)];
    _scrollviewBg.delegate = self;
    _scrollviewBg.contentSize = CGSizeMake(Dev_ScreenWidth*self.DataArry.count, Dev_ScreenHeight-64-30);
    _scrollviewBg.bounces = NO;
    [_scrollviewBg setPagingEnabled:YES];
    [_scrollviewBg setShowsHorizontalScrollIndicator:NO];
    [self addSubview:_scrollviewBg];
    
    
    
    for (int i =0 ;i<self.DataArry.count;i++)
    {
        ZilneListDataModel *zilneModel = [self.DataArry  objectAtIndex:i];
        
        UIImageView *iamgeview = [[UIImageView alloc]init];
        iamgeview.frame =CGRectMake((Dev_ScreenWidth-240)/2+Dev_ScreenWidth*i, 5, 240, 340);
        [iamgeview setUserInteractionEnabled:YES];
        iamgeview.tag = i;
        
        [iamgeview sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.hellomommy.cn%@",zilneModel.Cover]] placeholderImage:[UIImage imageNamed:@"bg"]];
        [iamgeview sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.hellomommy.cn%@",zilneModel.Cover]]];
        
        [_scrollviewBg addSubview:iamgeview];

        
        
        if(Dev_ScreenWidth==320)
        {
            iamgeview.frame =CGRectMake((Dev_ScreenWidth-240)/2+Dev_ScreenWidth*i, 10, 240, 240*780/560);
         
        }else if(Dev_ScreenWidth==375)
        {
            iamgeview.frame =CGRectMake((Dev_ScreenWidth-280)/2+Dev_ScreenWidth*i, 20, 280, 280*780/560);
            
        }else if(Dev_ScreenWidth==414)
        {
            iamgeview.frame =CGRectMake((Dev_ScreenWidth-320)/2+Dev_ScreenWidth*i, 30, 320, 320*780/560);

        }
        
        
        if (isIPHone4)
        {
             iamgeview.frame =CGRectMake((Dev_ScreenWidth-200)/2+Dev_ScreenWidth*i, 5, 200, 200*780/560);
        }
        
        
        UILabel *labelTitle = [[UILabel alloc] initWithFrame:CGRectMake((Dev_ScreenWidth-240)/2+Dev_ScreenWidth*i, iamgeview.bottom, 240, 30)];
        labelTitle.font = [UIFont boldSystemFontOfSize:16];  //UILabel的字体大小
        labelTitle.numberOfLines = 0;  //必须定义这个属性，否则UILabel不会换行
        labelTitle.textColor = RGBCOLOR(0, 0, 147);
        labelTitle.textAlignment = NSTextAlignmentCenter;  //文本对齐方式
        //[labelTitle setBackgroundColor:[UIColor redColor]];
        labelTitle.text =zilneModel.Name;
        [_scrollviewBg addSubview:labelTitle];
        
        UILabel *labelQiHao= [[UILabel alloc] initWithFrame:CGRectMake((Dev_ScreenWidth-240)/2+Dev_ScreenWidth*i, labelTitle.bottom, 240, 20)];
        labelQiHao.font = [UIFont boldSystemFontOfSize:14];  //UILabel的字体大小
        labelQiHao.numberOfLines = 0;  //必须定义这个属性，否则UILabel不会换行
        labelQiHao.textColor = [UIColor grayColor];//RGBCOLOR(0, 0, 147);
        labelQiHao.textAlignment = NSTextAlignmentCenter;  //文本对齐方式
        //[labelQiHao setBackgroundColor:[UIColor redColor]];
        
        NSString *strrq = [NSString stringWithFormat:@"%@",zilneModel.IssueNo];//@"期号：%@",zilneModel.IssueNo];
        labelQiHao.text =strrq;
        [_scrollviewBg addSubview:labelQiHao];
        
        UILabel *labelTime = [[UILabel alloc] initWithFrame:CGRectMake((Dev_ScreenWidth-240)/2+Dev_ScreenWidth*i, labelQiHao.bottom, 240, 20)];
        labelTime.font = [UIFont boldSystemFontOfSize:14];  //UILabel的字体大小
        labelTime.numberOfLines = 0;  //必须定义这个属性，否则UILabel不会换行
        labelTime.textColor =[UIColor grayColor];// RGBCOLOR(0, 0, 147);
        labelTime.textAlignment = NSTextAlignmentCenter;  //文本对齐方式
        //[labelTime setBackgroundColor:[UIColor redColor]];
        NSString *strqh = [NSString stringWithFormat:@"%@",zilneModel.ReleaseDate];//@"日期：%@",zilneModel.ReleaseDate];

        labelTime.text =strqh;
        [_scrollviewBg addSubview:labelTime];
        
        
        
        UITapGestureRecognizer* singleRecognizer;
        singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTapFrom:)];
        singleRecognizer.numberOfTapsRequired = 1; // 单击
        singleRecognizer.view.tag =i;
        [iamgeview addGestureRecognizer:singleRecognizer];
  
        
    }
    





}




-(void)handleSingleTapFrom:(UITapGestureRecognizer *)taogestue
{
    
    
    [self.delegaeZline pushViewContorllDelegat:self.DataArry[taogestue.view.tag]];
  

 }






@end
